package com.inforich.web.controller.planreport;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inforich.common.annotation.Log;
import com.inforich.common.core.controller.BaseController;
import com.inforich.common.enums.BusinessType;
import com.inforich.common.utils.poi.ExcelUtil;
import com.inforich.planreport.domain.RubbishPlanReport;
import com.inforich.planreport.domain.RubbishPlanReportCell;
import com.inforich.planreport.service.IRubbishPlanReportService;

/**
 * 固废排放计划申报单统计Controller
 *
 * @author liujie
 * @date 2022-11-28
 */
@RestController
@RequestMapping("/report/planreport")
public class RubbishPlanReportController extends BaseController {
    @Autowired
    private IRubbishPlanReportService rubbishPlanReportService;

    /**
     * 查询固废排放计划申报单统计列表
     */
    @PreAuthorize("@ss.hasPermi('report:planreport:list')")
    @GetMapping("/list")
    public Page<RubbishPlanReportCell> list(Page<RubbishPlanReportCell> page, RubbishPlanReport rubbishPlanReport) {
        Map<String, Object> map = beanToMap(rubbishPlanReport);
        rubbishPlanReportService.pageRubbishPlanReportCell(page, map);
        return page;
    }

    /**
     * 导出固废排放计划申报单统计列表
     */
    @PreAuthorize("@ss.hasPermi('report:planreport:export')")
    @Log(title = "固废排放计划申报单统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RubbishPlanReport rubbishPlanReport) {
        Map<String, Object> map = beanToMap(rubbishPlanReport);
        List<RubbishPlanReportCell> list = rubbishPlanReportService.listRubbishPlanReportCell(map);
        ExcelUtil<RubbishPlanReportCell> util = new ExcelUtil<RubbishPlanReportCell>(RubbishPlanReportCell.class);
        util.exportExcel(response, list, "固废排放计划申报单统计数据");
    }
}
